# n = x//p(i)
# x= x - n*p(i)


class Solution:
    def intToRoman(self, num: int) -> str:
        p = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
        q = ["M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I"]
        i = 0
        n = 0
        res = ""
        while num > 0:
            n = num // p[i]
            res = res + n * q[i]
            num = num - n * p[i]
            i = i + 1
        return res
